package exo1;

import exo1.CompteLimite;

public class CompteEpargne extends CompteLimite {

	private final double credit;
	private static final double MINIMUM = 300;
	private static final double TAUX = 15;

	public CompteEpargne(String nom, double plafond, double solde, int numero, double credit) {
		super(nom, numero, solde, plafond);
		this.credit = credit;
	}

	@Override
	public boolean debiterCompte(double montant) throws MonException
	{
		if (this.getOuvert() == true)
		{
			if (this.getSolde() - montant < 0 || this.getSolde() - montant < this.MINIMUM)
				return false;
			else
			{
				this.setSolde(getSolde() - montant);
				return true;

			}
		} 
		else
			throw new MonException("Operation impossible");
		
	}
	

	public boolean calculerInteret(int mois) throws  MonException
	{
		if (this.getOuvert() == true)
		{
			double tauxmois = this.TAUX / 100 / 12 * mois;
			this.setSolde(getSolde() + (this.getSolde() * tauxmois));
			return true;
		} else
			throw new MonException("Operation impossible");
	}

}
